import React, { memo } from 'react'
import { Table } from 'antd'
import { TableContent } from './style';
const table = [];
const titleList = [
    "设备名称",
    "状态",
    '平均日产能（吨）'
];
const itemIndex = [
    "name",
    "statuses",
    'enengry',
];
const dataParam = [
    {
        name: "9#",
        statuses: '运行中',
        enengry: 8

    },
    {
        name: "9#",
        statuses: '运行中',
        enengry: 12
    },
    {
        name: "9#",
        statuses: '停止',
        enengry: 6
    },
    {
        name: "9#",
        statuses: '运行中',
        enengry: 9
    },
    {
        name: "9#",
        statuses: '停止',
        enengry: 8
    },
];
const TableComponent = memo(() => {
    const setRowclass = (record, index) => {
        if (record.statuses === '停止') {
            return 'rowClass'
        }
        if (index % 2 !== 0) {
            return 'bcClass'
        }

    }
    const tableInit = () => {
        titleList.forEach((item, index) => {
            table.push({
                title: item,
                dataIndex: itemIndex[index],
                key: itemIndex[index],
                className: itemIndex[index],
            });
        });
        return table
    }
    return (
        <TableContent>
            <Table rowClassName={setRowclass} columns={tableInit()} dataSource={dataParam} size='middle' pagination={false} scroll={false} />
        </TableContent>
    )
})

export default TableComponent